package com.boilermaker.demo.service;

import com.boilermaker.demo.mapper.UserMapper;
import com.boilermaker.demo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public User selectUserByName(String userName) {
        return userMapper.selectUserByName(userName);
    }

    public boolean checkLogin(String userName, String password) {
        if (!StringUtils.hasLength(userName) || !StringUtils.hasLength(password)) return false;
        User user = selectUserByName(userName);
        if (user == null) return false;
        return password.equals(user.getPassword());
    }
}
